package com.kwan.x_im.data;


import com.kwan.x_im.data.http.HttpTokenManager;
import com.kwan.xframe.mvvm.BaseManager;
import com.kwan.xframe.mvvm.BaseTokenManager;
import com.kwan.xframe.mvvm.data.source.http.HttpResult;

import io.reactivex.rxjava3.core.Flowable;

/**
 * @author kwan
 * @date 2023/2/17 10:06
 * @Describe
 */
public class DataManager extends BaseManager {

	public static volatile DataManager instance = null;

	public static DataManager getInstance() {
		if (instance == null) {
			synchronized (DataManager.class) {
				if (instance == null) {
					instance = new DataManager();
				}
			}
		}
		return instance;
	}

	private DataManager() {
		mAppRepository = AppRepository.getInstance();
	}

	public AppRepository mAppRepository;

	@Override
	public BaseTokenManager getBaseTokenManager() {
		return HttpTokenManager.getInstance();
	}

	public Flowable<HttpResult<Object>> checkToken(String idToken) {
		return execute(mAppRepository.checkToken(idToken));
	}

//	public Flowable<HttpResult<Object>> refreshToken(String token) {
//		return execute(mAppRepository.refreshToken(token));
//	}




	public Flowable<HttpResult<Object>> orderSn(String googleUserId, String productId) {
		return executeWithToken(mAppRepository.orderSn(googleUserId, productId));
	}

	public Flowable<HttpResult<Object>> verifyOrder(String jsonData) {
		return executeWithToken(mAppRepository.verifyOrder(jsonData));
	}

	public Flowable<HttpResult<Object>> purchaseChapter(String googleUserId, String novelId, String chapterIds) {
		return executeWithToken(mAppRepository.purchaseChapter(googleUserId, novelId, chapterIds));
	}



}
